package com.car.controller;	

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.car.entity.Cartypetable;
import com.car.entity.User;
import com.car.service.CartypetableService;
import com.car.service.UserService;

@Controller
public class UserController {
	@Autowired
	CartypetableService cartypetableService;
	@Autowired
	UserService userService;
	@RequestMapping("")
	public String index(){
		return "index";
	}
	
	@RequestMapping("/shouye")
	public String shouye(){
		return "shouye";
	}
	
	@RequestMapping("/cartypetableList")
	public String cartypetableList(Model model){
		List<Cartypetable>cartype=cartypetableService.selectAll();
		model.addAttribute("cartype",cartype);
		return "cartypetableList";
	}
	
	@RequestMapping("/login")
	public String login(){
		return "login";
	}
	
	@RequestMapping("/logins")
	public String logins(User  user){
		User u=userService.adminLogin(user);
		if(u==null){
			return "redirect：login";
		}
		return "index";
	}
	
	@RequestMapping("/userList")
	public String userList(Model model){
		List<User> userList = userService.selectUser();
		model.addAttribute("userList",userList);
		return "userList";
	}
	
}
